package com.java.huxb.day02;

import java.lang.reflect.Constructor;

class  People {
    private String name;
    private Integer age;

    public People(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public  String getPeopleName() {
        return  this.name;
    }
    @Override
    public String toString() {
        return "People{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

/**
 * @author huxb
 * @date 2020/3/2 0002 下午 9:59
 * 由于有参构造方法参数规格不统一，所以再简单构造方法时必须添加无参构造方法
 */
public class Test003 {
    public static void main(String[] args) throws  Exception {
        Class<?>  peopleClass = Class.forName("com.java.huxb.day02.People");
        Constructor<?> constructor = peopleClass.getConstructor(String.class, Integer.class);
        Object people = constructor.newInstance("小明", 20);
        System.out.println(people);
    }
}
